"""
The length of the Moscow Ring Road (MKAD) is 109 kilometers. Biker Vasya starts from the zero kilometer of MKAD and drives with a speed of V kilometers per hour. On which mark will he stop after T hours?

Input data format

The program gets integers V and T as input. If V > 0, then Vasya moves in a positive direction along MKAD, if the value of V < 0 – in the negative direction. 0 ≤ T ≤ 1000, -1000 ≤ V ≤ 1000.

Output data format

The program should output an integer from 0 to 108 - the mark on which Vasya stops.

莫斯科环路（MKAD）的长度为109公里。 Biker Vasya从MKAD的零公里处开始，以每小时V公里的速度行驶。 T小时后他会停在哪个标记上？

输入数据格式

程序获取整数V和T作为输入。 如果V> 0，则Vasya沿MKAD沿正方向移动，如果V <0的值沿负方向移动。 0≤T≤1000，-1000≤V≤1000。

输出数据格式

程序应输出0到108之间的整数-Vasya停止的标记。

"""

speed, time = int(input()), int(input())
if 0 <= time <= 1000 and 1000 >= speed >= -1000:
    print((speed * time) % 109)
